package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.annotation.AutoFill;
import com.sky.dto.SetmealPageQueryDTO;
import com.sky.entity.Setmeal;
import com.sky.enumeration.OperationType;
import com.sky.vo.SetmealVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface SetmealMapper {

    //添加新套餐
    @AutoFill(value = OperationType.INSERT)
    void insert(Setmeal setmeal);

    /**
     * 分页展示套餐
     * @param setmealPageQueryDTO
     * @return
     */
    Page<SetmealVO> select(SetmealPageQueryDTO setmealPageQueryDTO);

    //根据套餐id查询套餐
    SetmealVO selectById(Long id);


    /**
     * 修改套餐
     * @param setmeal
     */
    @AutoFill(value = OperationType.UPDATE)
    void updataSetmeal(Setmeal setmeal);

    /**
     * 删除套餐
     * @param id
     */
    @Delete("delete from setmeal where id=#{id}")
    void delectSetmeal(String id);

    //用户端根据分类id查询套餐
    @Select("select * from setmeal where category_id = #{categoryId}")
    List<Setmeal> selectByCategoryId(String categoryId);

    //根据状态查询套餐数量
    @Select("select count(id) from setmeal where status = #{status}")
    Integer getNumberByStatus(int status);



}
